/*******************************************************************

    Author: Xiao
    Date: 2022/3/29 17:40

*******************************************************************/
package dao

type Attach struct {
	AttachId			int		`gorm:"primarykey" json:"attach_id"`
	AttachPath			string 	`json:"attach_path"`
	AttachUsed			int 	`json:"attach_used"`
	AttachThumb			string 	`json:"attach_thumb"`
	AttachType			string 	`json:"attach_type"`
	AttachSha			string 	`json:"attach_sha"`
	AttachSize			int64 	`json:"attach_size"`
	AttachUser			int 	`json:"attach_user"`
	AttachStatus		int 	`json:"attach_status"`
	AttachCreatetime	int64	`gorm:"autoCreateTime" json:"attach_createtime"`
	AttachUpdatetime	int64	`gorm:"autoUpdateTime" json:"attach_updatetime"`
}

// 保存上传的文件信息
func SaveAttach(a Attach) (Attach,error){
	result := MDB.Create(&a)
	return a,result.Error
}

// 获取上传文件
func GetAttach(aid int) (Attach,error) {
	var a Attach
	result := MDB.Where("attach_id = ?",aid).Find(&a)
	return a,result.Error
}